<?php
/**
 * Created by PhpStorm.
 * User: august
 * Date: 2021/5/18
 * Time: 14:27
 */

namespace DesignPatterns\Creator\SimpleFactory;


class Factory
{
    public function create($operate)
    {
        $obj = null;
        switch ($operate) {
            case '+':
                $obj = new Add();
                break;
            case '-':
                $obj = new Sub();
                break;
            case '*':
                $obj = new Mul();
                break;
            case '/':
                $obj = new Div();
                break;
            default:
                throw new \InvalidArgumentException("暂不支持该操作");
        }
        return $obj;
    }
}